package org.csu.mypetstore.controller;

import org.csu.mypetstore.domain.Order;
import org.csu.mypetstore.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/admin")
public class Admin_OrderController {
    @Autowired
    private OrderService orderService;

    @RequestMapping("/adminDeleteOrder")
    public String adminDeleteOrder(String orderId,Model model){
        //根据订单号删除订单
        orderService.deleteOrderByorderId(orderId);
        //重新获取订单列表
        List<Order> orderList = orderService.getAllOrders();
        model.addAttribute("orderList",orderList);
        return "redirect:/order/adminAllOrders";
    }
}
